<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
		<style type="text/css">
			div{
				border: black 1px solid;
				/* 增加相对定位，框才能移动 */
				position: relative;
			}
			#d1{width: 250px;height: 250px;}
			#d2{width: 200px;height: 200px;left: 25px;top: 25px;}
			#d3{width: 150px;height: 150px;left: 25px;top: 25px;}
			#d4{width: 100px;height: 100px;left: 25px;top: 25px;}
			#d5{width: 50px;height: 50px;left: 25px;top: 25px;}
		</style>
	</head>
	<body>
		<div id="d1">
			<div id="d2">
				<div id="d3">
					<div id="d4">
						<div id="d5">
						</div>
					</div>
				</div>
			</div>
		</div>
	<script type="text/javascript">
		var divs = document.querySelectorAll("div");
		for(let i = 0; i < 5; i++){
			divs[i].onmouseover = function(){
				event.target.setAttribute("style","background-color: gray;")
			}
			divs[i].onmouseout = function(){
				event.target.setAttribute("style","background-color: white;")
			}
		}
		</script>
				</div>
			</div>
		</div>
	</body>
</html>
